﻿using System.Diagnostics.Contracts;
using System.Text.RegularExpressions;

namespace ATM.Utilities
{
    class ValidationUtilities
    {
        static Regex creditCardRegex = new Regex("[1-9]{4}-[1-9]{4}-[1-9]{4}-[1-9]{4}");
        static Regex monthRegex = new Regex("1[0-2]|[1-9]");
        static Regex yearRegex = new Regex("2[0-9]{3}");
        static Regex pinRegex = new Regex("[0-9]{4}");

        [Pure]
        public static bool IsCreditCardNumber(string text)
        {
            Contract.Requires(text != null);
            return creditCardRegex.IsMatch(text);
        }

        [Pure]
        public static bool IsMonthNumber(string text)
        {
            Contract.Requires(text != null);
            return monthRegex.IsMatch(text);
        }

        [Pure]
        public static bool IsYearNumber(string text)
        {
            Contract.Requires(text != null);
            return yearRegex.IsMatch(text);
        }

        [Pure]
        public static bool IsPinCode(string text)
        {
            Contract.Requires(text != null);
            return pinRegex.IsMatch(text);
        }

        [Pure]
        public static bool IsYear(int year)
        {
            return year > 1999 && year < 3000;
        }

        [Pure]
        public static bool IsMonth(int month)
        {
            return month > 0 && month < 13;
        }
    }
}
